package com.shir.travels.ui.zhoubian;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.shir.travels.R;

public class ZhouBianDesc extends AppCompatActivity {

    public static final String INTENT_TITLE="com.shir.travels.ui.zhoubian@title";
    public static final String INTENT_IMG_RES="com.shir.travels.ui.zhoubian@img";
    public static final String INTENT_DESC="com.shir.travels.ui.zhoubian@desc";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhoubian_desc);

        CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar_zhoubian_desc);
        Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar_zhoubian_desc);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        }

        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        toolbar.setTitleTextAppearance(this,R.style.Toolbar_TitleText);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        getSupportActionBar().setDisplayShowTitleEnabled(false);


        Intent intent = getIntent();
        String title = intent.getStringExtra(INTENT_TITLE);
        String desc = intent.getStringExtra(INTENT_DESC);
        Integer imgRes = Integer.parseInt(intent.getStringExtra(INTENT_IMG_RES));

        TextView textViewTitle = (TextView)findViewById(R.id.textView38);
        ImageView imageView = (ImageView)findViewById(R.id.imageView42);
        TextView textViewDesc = (TextView)findViewById(R.id.textView40);

        textViewTitle.setText(Html.fromHtml(title,Html.FROM_HTML_MODE_LEGACY));
        textViewTitle.invalidate();
        imageView.setImageResource(imgRes);
        imageView.invalidate();
        textViewDesc.setText(Html.fromHtml(desc,Html.FROM_HTML_MODE_LEGACY));
        textViewDesc.invalidate();


    }
}
